#include <iostream>
#include <Windows.h>
#include "../dxsdk/Include/xnamath.h"


#pragma comment(lib, "../dxsdk/Lib/x86/d3dx11.lib")

using namespace std;

ostream& operator<<(ostream &os, FXMVECTOR v)
{
	XMFLOAT3 dest;

	XMStoreFloat3(&dest, v);

	os << "("<<dest.x<<", "<<dest.y<<", "<<dest.z<<")";
	return os;
}

int main()
{
	cout.setf(ios_base::boolalpha);

	if(!XMVerifyCPUSupport())
	{
		cout<<"No SIMD!"<<endl;
		return 0;
	}


	XMVECTOR n = XMVectorSet(1.0f, 0.0f, 0.0f, 0.0f);
	XMVECTOR u = XMVectorSet(1.0f, 2.0f, 3.0f, 0.0f);
	XMVECTOR v = XMVectorSet(-2.0f, 1.0f, -3.0f, 0.0f);
	XMVECTOR w = XMVectorSet(0.707f, 0.707f, 0.0f, 0.0f);

	//adunare
	XMVECTOR a = u + v;

	//scadere
	XMVECTOR b = u - v;

	//inmultire cu scalar
	XMVECTOR c = 10.0f * u;

	//||u||
	XMVECTOR L = XMVector3Length(u);
	
	//d = u / ||u||
	XMVECTOR d = XMVector3Normalize(u);

	//dot product
	XMVECTOR s = XMVector3Dot(u, v);

	//cross product
	XMVECTOR e = XMVector3Cross(u, v);

	//proiectia si perpendiculara
	XMVECTOR projW;
	XMVECTOR perpW;
	XMVector3ComponentsFromNormal(&projW, &perpW, w, n);

	bool equal = XMVector3Equal(projW + perpW, w) != 0;
	bool notEqual = XMVector3NotEqual(projW + perpW, w) != 0;

	//unghiul dintre proiectii 
	XMVECTOR angleVec = XMVector3AngleBetweenVectors(projW, perpW);

	float angleRadians = XMVectorGetX(angleVec);
	float angleDegrees = XMConvertToDegrees(angleRadians);

	cout<<"u	  = "<<u<<endl;
	cout<<"v	  = "<<v<<endl;
	cout<<"w	  = "<<w<<endl;
	cout<<"n	  = "<<n<<endl;
	cout<<"a = u + v = "<<a<<endl;
	cout<<"b = u - v = "<<b<<endl;
	cout<<"c = 10 * u	= "<<c<<endl;
	cout<<"d = u / ||u||= "<<d<<endl;
	cout<<"e = u x v	= "<<e<<endl;
	cout<<"L = ||u||	= "<<L<<endl;
	cout<<"s = u . v	= "<<s<<endl;
	cout<<"projW		= "<<projW<<endl;
	cout<<"perpW		= "<<perpW<<endl;
	cout<<"projW + perpW == w		= "<<equal<<endl;
	cout<<"projW + perpW != w		= "<<notEqual<<endl;
	cout<<"angle					= "<<angleDegrees<<endl;

	system("pause");

	return 0;
}
	